package gold.digger;

import gold.utils.InputUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC728 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public List<Integer> selfDividingNumbers(int left, int right) {
            List<Integer> ans = new ArrayList<>();
            while (left <= right) {
                int cur = left;
                while (cur > 0) {
                    int bit = cur % 10;
                    if (bit == 0) break;
                    if (left % bit != 0) break;
                    cur /= 10;
                }
                if (cur <= 0) ans.add(left);
                left++;
            }
            return ans;
        }
    }

    public void run() {
        System.out.println(new Solution().selfDividingNumbers(1, 22));
        System.out.println(new Solution().selfDividingNumbers(47, 85));
    }

    public static void main(String[] args) throws Exception {
        LC728 an = new LC728();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
